package com.onesports.intelligent.k12.polarlight.mapper.course;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.onesports.intelligent.k12.polarlight.annotation.DataPermission;
import com.onesports.intelligent.k12.polarlight.domain.dto.cls.ClassPageDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.market.ProductCourseDetailsDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.organization.CampusIdDTO;
import com.onesports.intelligent.k12.polarlight.domain.entity.course.ClassInfo;
import com.onesports.intelligent.k12.polarlight.domain.entity.sys.WxUser;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassPageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.ClassWxDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.cls.SellClaRuleInfoVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.*;
import com.onesports.intelligent.k12.polarlight.enums.DataPermissionTypeEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 班级
 *
 * @author
 * @since 1.0.0 2022-07-08
 */
@Mapper
public interface ClassInfoMapper extends BaseMapper<ClassInfo> {

    /**
     * 查询校区下学生数量
     * @param campusId 校区id
     * @return
     */
    Long selectStudentNumber(@Param("campusId") String campusId);
    /**
     * 获取拼班列表
     *
     * @param dto dto
     * @return {@link List}<{@link NearSpellClassVO}>
     */
    List<NearSpellClassVO> getNearSpellClassList(@Param("dto") CampusIdDTO dto);

    /**
     * 获取商品拼班列表
     *
     * @param dto dto
     * @return {@link List}<{@link ProductSpellClassVO}>
     */
    List<ProductSpellClassVO> getProductSpellClass(@Param("dto") ProductCourseDetailsDTO dto);

    /**
     * 机构端班级管理获取详情
     * @param page
     * @param dto
     * @param orgId 组织ID
     * @return
     */
    @DataPermission(tableName = "organization_campus",alias = "oc",value = DataPermissionTypeEnum.BY_CAMPUS)
    IPage<ClassPageVO> getClassDetail(Page<ClassPageVO> page, @Param("dto") ClassPageDTO dto,@Param("orgId") String orgId);

    /**
     * 根据ID获取班级详情
     * @param classId 班级ID
     * @param orgId
     * @return class_merge_rule ID,确定班型
     */
    ClassDetailVO getDetailByClassId(@Param("classId") String classId,
                                     @Param("orgId") String orgId);


    @DataPermission
    List<SpellClassInfoVO> spellClassInfo(@Param("scheduleDetailIds") List<String> scheduleDetailIds,
                                          @Param("status") String status,
                                          @Param("coachId") String coachId);

    /**
     * 会员端，班级列表
     * @param classId 班级ID
     * @param orgId 机构ID
     * @param isCoach 是否为教练，教练查全部状态
     * @return
     */
    List<ClassWxDetailVO> getWxClassList(@Param("classId") List<String> classId,
                                         @Param("orgId") String orgId,
                                         @Param("isCoach") Boolean isCoach,
                                         @Param("accId") String accId);

    /**
     * 获取班级拼班规则价格信息
     * @param classId 班级id
     * @return  SellClaRuleInfoVO
     */
    SellClaRuleInfoVO spellClaRuleByClaId(@Param("classId") String classId);

    /**
     * 获取班级信息
     *
     * @return {@link List}<{@link ClassScheduleVO}>
     */
    List<ClassScheduleVO> findClassSchedule();

    /**
     * 获取班级拼班规则价格信息
     * @param classIds 班级id
     * @return  SellClaRuleInfoVO
     */
    List<SellClaRuleInfoVO> spellClaRuleByClaIds(@Param("classIds") List<String> classIds);

    /**
     * 查询拼班中的班级信息
     *
     * @return {@link List}<{@link ClassInfo}>
     */
    List<ClassMinNumVO> getSpellClassInfoList();

    /**
     * 根据班级id获取家长的openId集合
     * @param classInfoId 班级id
     * @return 家长的openId集合
     */
    List<WxUser> getParentWxUsers(@Param("id") String classInfoId);

    /**
     * 根据classId查找最小开班条件
     * @param classId
     * @return
     */
    Integer getMinNumByClassInfoId(@Param("classId") String classId);
}
